package com.rgp.apipassenger.controller;

import com.rgp.internalcommon.dto.TokenRequest;
import com.rgp.apipassenger.service.TokenRefreshService;
import com.rgp.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-13 4:14
 */
@RestController
public class TokenController {

    @Autowired
    private TokenRefreshService tokenRefreshService;

    @PostMapping("/refresh-token")
    public ResponseResult refreshToken(@RequestBody TokenRequest tokenRequest){
        ResponseResult responseResult = null;
        //1.获取refreshToken
        String refreshToken = tokenRequest.getRefreshToken();

        //2.刷新双token并颁发给乘客
        try {
            responseResult = tokenRefreshService.refreshToken(refreshToken);
        }catch(Exception exception){
            // have noting to do
        }
        return responseResult;
    }
}